//
//  ViewController.swift
//  Swift的图文混排
//
//  Created by YYY on 2017/8/28.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var attributeLabel: UILabel!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //附件
        let attachment = NSTextAttachment()
        attachment.image = #imageLiteral(resourceName: "表情")
        attachment.bounds = CGRect(x: 0, y: 0, width: attributeLabel.font.lineHeight, height: attributeLabel.font.lineHeight)
        //设置图片文本属性
        let imageStr = NSAttributedString(attachment: attachment)
        
        //设置纯文本属性
        let textStr = NSMutableAttributedString(string: "我")
        
        //拼接图片、文本
        textStr.append(imageStr)
        
        let string1 = NSAttributedString(string: "hello")
        textStr.append(string1)
        
        attributeLabel.attributedText = textStr
        
        
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

